package com.blb.zycommunity.service.impl;

import com.blb.zycommunity.entity.SysDept;
import com.blb.zycommunity.mapper.SysDeptMapper;
import com.blb.zycommunity.service.ISysDeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.zycommunity.utils.TreeUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author chenheng
 * @since 2023-11-20
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {

    @Resource
    private SysDeptMapper deptMapper;

    @Override
    public List<SysDept> findDeptWithChildren() {
        return deptMapper.selectDeptWithChildren();
    }
    @Resource
    private SysDeptMapper sysDeptMapper;



    @Override
    public List<SysDept> selectAll() {
        List<SysDept> deptList = sysDeptMapper.selectAll();
        List<SysDept> sysDepts = TreeUtils.deptsToTree(deptList);
        return sysDepts ;
    }

    @Override
    public List<SysDept> selectByName(String deptName, Long status) {
        List<SysDept> sysDepts = sysDeptMapper.selectByName(deptName, status);
        return sysDepts;
    }


}
